package com.common.facebody.config;

import com.common.facebody.exception.FaceBodyBaseException;
import com.common.facebody.exception.FaceBodyExceptionMsg;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;


/**
 * @author 牧鱼
 * @date 2021年4月25日
 * 人脸识别服务key
 */

@ConfigurationProperties( value = "alibaba.facebody" )
@Component
public class FaceBodyConfig {

    /**
     * 阿里云主账号AccessKey，accessKeySecret拥有所有API的访问权限
     */
    private String accessKeyId ;
    private String accessKeySecret ;

    /**
     * https://help.aliyun.com/document_detail/40654.html?spm=a2c6h.13066369.0.0.54a17471VgnWQs
     */
    private String regionId ;

    /**
     * 人脸比分 （默认）
     */
    private Float faceBodyScore = new Float(0.8);

    public String getAccessKeyId() {
        return accessKeyId;
    }

    public void setAccessKeyId(String accessKeyId) {
        this.accessKeyId = accessKeyId;
    }

    public String getAccessKeySecret() {
        return accessKeySecret;
    }

    public void setAccessKeySecret(String accessKeySecret) {
        this.accessKeySecret = accessKeySecret;
    }

    public String getRegionId() {
        return regionId;
    }

    public void setRegionId(String regionId) {
        this.regionId = regionId;
    }

    public Float getFaceBodyScore() {
        return faceBodyScore;
    }

    public void setFaceBodyScore(Float faceBodyScore) {
        if (faceBodyScore < 0.0 || faceBodyScore > 1.0){
            throw new FaceBodyBaseException(FaceBodyExceptionMsg.FACEBODY_SCORE_ERROR);
        }
        this.faceBodyScore = faceBodyScore;
    }
}
